package com.sthz.facepay.mapper;

import static org.apache.ibatis.jdbc.SqlBuilder.BEGIN;
import static org.apache.ibatis.jdbc.SqlBuilder.INSERT_INTO;
import static org.apache.ibatis.jdbc.SqlBuilder.SET;
import static org.apache.ibatis.jdbc.SqlBuilder.SQL;
import static org.apache.ibatis.jdbc.SqlBuilder.UPDATE;
import static org.apache.ibatis.jdbc.SqlBuilder.VALUES;
import static org.apache.ibatis.jdbc.SqlBuilder.WHERE;

import com.sthz.facepay.model.Interval;

public class IntervalSqlProvider {

    public String insertSelective(Interval record) {
        BEGIN();
        INSERT_INTO("st_interval");
        
        if (record.getId() != null) {
            VALUES("id", "#{id,jdbcType=INTEGER}");
        }
        
        if (record.getCycle() != null) {
            VALUES("cycle", "#{cycle,jdbcType=VARCHAR}");
        }
        
        if (record.getStart_time() != null) {
            VALUES("start_time", "#{start_time,jdbcType=TIMESTAMP}");
        }
        
        if (record.getEnd_time() != null) {
            VALUES("end_time", "#{end_time,jdbcType=TIMESTAMP}");
        }
        
        return SQL();
    }

    public String updateByPrimaryKeySelective(Interval record) {
        BEGIN();
        UPDATE("st_interval");
        
        if (record.getCycle() != null) {
            SET("cycle = #{cycle,jdbcType=VARCHAR}");
        }
        
        if (record.getStart_time() != null) {
            SET("start_time = #{start_time,jdbcType=TIMESTAMP}");
        }
        
        if (record.getEnd_time() != null) {
            SET("end_time = #{end_time,jdbcType=TIMESTAMP}");
        }
        
        WHERE("id = #{id,jdbcType=INTEGER}");
        
        return SQL();
    }
}